package com.learner.pojo.trade;

import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

@Data
@Entity
@Table(name = "trade_order")
@SQLDelete(sql = "update trade_order set is_deleted = 1 where id = ?")
@Where(clause = "is_deleted = 0")
@GenericGenerator(name = "jpa-uuid", strategy = "uuid")
@EntityListeners(AuditingEntityListener.class)
public class Order implements Serializable {

    private static final long serialVersionUID = -4317691823507504363L;
    @Id
    @GeneratedValue(generator = "jpa-uuid")
    private String id;
    @Column(name = "order_no")
    private String orderNo;
    @Column(name = "course_id")
    private String courseId;

    @Column(name = "course_title")
    private String courseTitle;
    @Column(name = "course_cover")
    private String courseCover;
    @Column(name = "teacher_name")
    private String teacherName;
    @Column(name = "member_id")
    private String memberId;
    private String nickname;
    private String mobile;
    private BigDecimal totalFee;
    @Column(name = "pay_type")
    private Integer payType;
    private Integer status;
    @Column(name = "is_deleted")
    private Boolean deleted = false;
    @Override
    public int hashCode() {
        return 0;
    }

    @CreatedDate
    @Column(name = "gmt_create")
    private Date gmtCreate;

    /**
     * 修改时间
     */
    @LastModifiedDate
    @Column(name = "gmt_modified")
    private Date gmtModified;


}
